#ifndef ROUTER_H
#define ROUTER_H

#include <QString>
#include <QVariantMap>
#include <QStackedWidget>

// 路由数据结构
struct Router
{
   QString router_name;     // 路由器名称
   QVariantMap params;      // 参数
};

Q_DECLARE_METATYPE(Router);     // 将 Router 注册到 Qt 的元对象系统中

class RouterManager : public QObject {
    Q_OBJECT

private:
    QStackedWidget *stackedWidget;
    QMap<QString, QWidget*> stacked_routers;

public:
    RouterManager(QStackedWidget *stackedWidget, QObject *parent = nullptr);

    void registerRouter(QString router_name, QWidget *widget);
    bool navigateTo(const QString &router_name, const QVariantMap &params = {});

signals:
    void routeChanged(const QString &router_name, const QVariantMap &params);


};



#endif